﻿using Shadowsocks.Controller;
using Shadowsocks.Model;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace shadowsocks_winservice
{
    public partial class Service1 : ServiceBase
    {
        public Configuration config;
        public Listener service;

        public Service1()
        {
            InitializeComponent();        
        }

        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            config = Configuration.Load();
            Local serv = new Local(config);
            List<Listener.Service> list = new List<Listener.Service>();
            list.Add(serv);
            service = new Listener(list);
            service.Start(config);
        }

        protected override void OnStop()
        {
            base.OnStop();

            service.Stop();
        }
    }
}
